<!DOCTYPE html>
<html>
<head>
	<!-- 公共页面 -->
	<#include "/admin/view/include/common.html">
	<!-- 公共页面 /-->
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div class="wrapper">
        <!-- 页面头部 -->
        <#include "/admin/view/include/header.html">
        <!-- 页面头部 /-->
        <!-- 导航侧栏 -->
        <#include "/admin/view/include/menu.html">
        <!-- 导航侧栏 /-->
        <!-- 内容区域 -->
        <div class="content-wrapper" id="contentDiv">
            <!-- 正文区域 -->
            <section class="content">
            	<form id="inputForm" action="${base}/admin/site/update" method="post">
           		<input type="hidden" name="id" value="${site.id}">
				<!--表单信息-->
                <div class="panel panel-default" style="padding-bottom: 10px;">
                    <div class="panel-heading">站点信息</div>
                    <div class="row data-type">
                        <div class="col-md-2 title">名称</div>
                        <div class="col-md-10 data">
                            <input type="text" class="form-control" placeholder="名称" name="name" value="${site.name}">
                        </div>
                        <div class="col-md-2 title">类型</div>
                        <div class="col-md-10 data">
                            <div class="form-group form-inline">
                                <div class="radio"><label><input type="radio" name="type" value="0" <#if site.type==0> checked </#if>> 目录</label></div>
                                <div class="radio"><label><input type="radio" name="type" value="1" <#if site.type==1> checked </#if>> 域名</label></div>
                            </div>
                        </div>
                        <div class="col-md-2 title" id="domain_title" <#if site.type==0> style="display: none;" </#if>>域名</div>
                        <div class="col-md-10 data" id="domain_data" <#if site.type==0> style="display: none;" </#if>>
                            <input type="text" class="form-control" placeholder="域名" name="domain" value="${site.domain}">
                        </div>
                        <div class="col-md-2 title" id="protocol_title" <#if site.type==0> style="display: none;" </#if>>协议</div>
                        <div class="col-md-10 data" id="protocol_data" <#if site.type==0> style="display: none;" </#if>>
                            <select class="form-control" name="protocol">
                                <option value="">请选择</option>
                                <option value="http://" <#if "http://"==site.protocol> selected </#if>>http://</option>
                                <option value="https://" <#if "https://"==site.protocol> selected </#if>>https://</option>
                            </select>
                        </div>
                        <div class="col-md-2 title" id="cat_title" <#if site.type==1> style="display: none;" </#if>>目录</div>
                        <div class="col-md-10 data" id="cat_data" <#if site.type==1> style="display: none;" </#if>>
                            <input type="text" class="form-control" placeholder="目录" name="cat" value="">
                        </div>
                        <div class="col-md-2 title">PC模板</div>
                        <div class="col-md-10 data">
                            <select class="form-control" name="pcTemplate">
                                <#list templates as template>
                                <option value="${template}" <#if template==site.pcTemplate> selected </#if>>${template}</option>
                                </#list>
                            </select>
                        </div>
                        <div class="col-md-2 title">手机端</div>
                        <div class="col-md-10 data">
                            <div class="row">
                                <div class="col-md-2">
                                    <div class="form-group form-inline">
                                        <div class="radio"><label><input type="radio" name="isMobile" value="0" <#if site.isMobile==0> checked </#if>> 无</label></div>
                                        <div class="radio"><label><input type="radio" name="isMobile" value="1" <#if site.isMobile==1> checked </#if>> 有</label></div>
                                    </div>
                                </div>
                                <div class="col-md-3">
                                    <select class="form-control" name="mobileTemplate" id="mobileTemplate" style="display: none;">
                                        <#list templates as template>
                                        <option value="${template}" <#if template==site.mobileTemplate> selected </#if>>${template}</option>
                                        </#list>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
	                <!--工具栏-->
	                <div class="box-tools text-center">
	                    <button type="submit" class="btn bg-maroon">保存</button>
	                    <button type="button" class="btn bg-default" onclick="history.back(-1);">返回</button>
	                </div>
	                <!--工具栏/-->
                </div>
                <!--表单信息/-->
                </form>
            </section>
            <!-- 正文区域 /-->
        </div>
        <!-- 内容区域 /-->
        <!-- 底部导航 -->
        <#include "/admin/view/include/footer.html">
        <!-- 底部导航 /-->
    </div>
</body>
</html>
<!---->
<script>
 $(document).ready(function() {
     // 激活导航位置
     setSidebarActive("admin-site");
 });
</script>
<script type="text/javascript">
$().ready(function() {

	var $inputForm = $("#inputForm");

    //手机端模板
    $("input[name='isMobile']").on("click",function () {
        var type = $(this).val();
        if(type==0){
            $("#mobileTemplate").hide();
        }else if(type==1){
            $("#mobileTemplate").show();
        }
    });

    //类型
    $("input[name='type']").on("click",function () {
        var type = $(this).val();
        if(type==0){
            $("#domain_title").hide();
            $("#domain_data").hide();
            $("#protocol_title").hide();
            $("#protocol_data").hide();
            $("#cat_title").show();
            $("#cat_data").show();
        }else if(type==1){
            $("#domain_title").show();
            $("#domain_data").show();
            $("#protocol_title").show();
            $("#protocol_data").show();
            $("#cat_title").hide();
            $("#cat_data").hide();
        }
    });
	
	// 表单验证
	$inputForm.validate({
		rules: {
			name: "required",
			template: "required"
		}
	});

});
</script>
